import React, { Component } from 'react'
import { observer, inject } from 'mobx-react'
@inject('store') // 依赖注入   内层组件引入 store,类似于vue的provide/inject
@observer // 这个组件可以检测状态的改变
class App extends Component {
  componentDidMount() {
    fetch('http://121.89.205.189/api/banner/list')
    .then(res => res.json())
    .then(res => {
        console.log(res.data)
        this.props.store.changeBannerList(res.data)
      })
  }
  render() {
    console.log('3333', this.props.store.bannerList)
    return (
      <div>
        {
          this.props.store.bannerList && this.props.store.bannerList.map(item => {
            return <img src={ item.img } alt={item.alt} key = { item.bannerid }/>
          })
        }
        12
      </div>
    )
  }
}

export default  App